<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript"
	src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
	function validate (fieldName, fieldInfo){
	//	$('#' + fieldName).keyup(function(event){
			var field = $('#' + fieldName).val();
				$.ajax ({
					url: 'addClient',
					type: 'post',
					data: {
						inputName: fieldName,
						fieldValue: field,
						fieldInfo: fieldInfo
						}
					dataType: 'json',
					success: function(data) 
{
						$('#' + fieldInfo).html(data.fieldInfo);
	}
					});
			});
		}
		//$("input[type='submit']").prop("disabled", true);

		//var username = document.getElementById("username");
		
		
		   
//		$('#username').keyup(function(event) 
	//	{
		//	var usernameField = $("#username").val();
			//	$.ajax
				///({
					//url : 'addClient',
					//type : 'post',
					//dataType : 
					//{
					//username : usernameField
					//},
					//dataType : 'json',
					//success : function(data) 
					//{
						//$('#usernameNote').html(data.usernameNote);
						//if (data.usernameNote === "OK")
						//{
						//usernameOK = true;
						//}
						//else usernameOK = false;
					//}
				//});
			//return usernameOK;
		//}


		
		//console.log("usernameOK: " + usernameOK);
		//if (usernameOK == true)
		//	$("input[type='submit']").prop("disabled", false);
//	});
</script>
</head>
<body>

	Login:
	<input type="text" id="username" onkeyup="validate(this.id, 'usernameNote');" />
	<div id="usernameNote"></div>
	<br />
	<input type="submit" value="Wyślij mnie" />

</body>
</html>
